<?
/**
 * class <b>Hli_Serializer Class</b>
 * Published 21/12/2010 03:45:13
 *
 * This is a top-level class inherited by most of the HLI business object classes
 * (e.g. Hli_AddressType, etc). It provides serialization functionality necessary for
 * SOAP communication with the server.
 *
 * @author Lars Sorhus (lars@saucecode.com.au)
 * @copyright sauceCode Pty Ltd.
 * @version 2.0.5.105.
 * @internal It's not recommended at all to modify this code.
 */
class Hli_Serializer{
	public $data=array();

	private $__response=array();
	private $__errors;
	private $__nusoapRequest;
	private $__nusoapResponse;
	private $__nusoapDebugOutput;

	public function  __construct(){
		$this->data=array();
	}

	/**
    * Gets the HLI errors.
    *
	 * @method getErrors
	 * @return Hli_ErrorType[]
	 */
	public function getErrors(){
		return($this->__errors);
	}

	/**
    * Add an HLI type error to an HLI object.
    *
	 * @method addError
	 * @param Hli_ErrorType
	 * @return void
	 */
	public function addError(Hli_ErrorType $error){
		$this->__errors[]=$error;
	}

	/**
    * Gets the registration credentials.
    *
	 * @method getRegisterCredentials
	 * @return Hli_RegisterCredentialsType
	 */
	public function getRegisterCredentials(){
		return($this->data["RegisterCredentials"]);
	}
	/**
    * Sets the registration credentials.
    *
	 * @method setRegisterCredentials
	 * @param Array
	 * @return void
	 */
	public function setRegisterCredentials($obj){
		$this->data["RegisterCredentials"]=$obj;
	}

	/**
    * A getter method for the __response member.
    *
	 * @method getRequestObject
	 * @return Array
	 */
	public function getResponseObject(){
		return($this->__response);
	}

	/**
    * Get the NuSoap request.
    *
	 * @method getNuSoapRequest
	 * @return string
	 */
	public function getNuSoapRequest(){
		return($this->__nusoapRequest);
	}

	/**
    * Set the NuSoap request.
    *
	 * @method setNuSoapRequest
	 * @param string
	 * @return void
	 */
	public function setNuSoapRequest($value){
		$this->__nusoapRequest=$value;
	}

	/**
    * Get the NuSoap response.
    *
	 * @method getNuSoapResponse
	 * @return string
	 */
	public function getNuSoapResponse(){
		return($this->__nusoapResponse);
	}

	/**
    * Set NuSoap response.
    *
	 * @method setNuSoapResponse
	 * @param string
	 * @return void
	 */
	public function setNuSoapResponse($value){
		$this->__nusoapResponse=$value;
	}

	/**
    * Get the NuSoap debug output.
    *
	 * @method getNuSoapDebugOutput
	 * @return string
	 */
	public function getNuSoapDebugOutput(){
		return($this->__nusoapDebugOutput);
	}

	/**
    * For making use of the SOAP debug framework explicitly, set the debug output.
    *
	 * @method setNuSoapDebugOutput
	 * @param string
	 * @return void
	 */
	public function setNuSoapDebugOutput($value){
		$this->__nusoapDebugOutput=$value;
	}

	/**
    * Gets the acknowledgement variable within response
    *
	 * @method getAck
	 * @return string
	 */
	public function getAck(){
		return($this->__response["Ack"]);
	}
	/**
    * Sets the acknowledgement variable within response
    *
	 * @method setAck
	 * @param string
	 * @return void
	 */
	public function setAck($value){
		$this->__response["Ack"]=$value;
	}

	/**
    * Serializes the object for SOAP protocol.
    *
	 * @method serialize
	 * @return Array
	 */
	public function serializeToArray(){
		$data=$this->data;
		foreach($data as $key=>$value){
			if(get_class($value)){
//				print("<p>$key is a class: ".get_class($value)."</p>");
				if(is_subclass_of($value,"Hli_Serializer")){
//					print("<p>".get_class($value)." is also a subclass of Hli_Serializer.</p>");
					$data[$key]=$data[$key]->serializeToArray();
//					print("<pre>");
//					print_r($data[$key]);
//					print("</pre>");
				}
			}
		}
		return($data);
	}
}
?>
